package com.liuc.mybatis;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class FunctionDemo {
    public static void main(String[] args) {
//        Function<String,Integer> function = new Function<String, Integer>() {
//            @Override
//            public Integer apply(String s) {
//                return s.length();
//            }
//        };
        Function<String,Integer> function = s ->{return  s.length();};
        System.out.println(function.apply("abc"));
//        Consumer<String> consumer = new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//
//            }
//        }
        Consumer<String> consumer = s -> { System.out.println(s.length());};
        consumer.accept("aaaa");
        /*Supplier<String>  supplier = new Supplier<String>() {
            @Override
            public String get() {
                return null;
            }
        }*/
        Supplier<String>  supplier = () ->{return "a";};
        System.out.println(supplier.get());

//        Predicate<String> predicate = new Predicate<String>() {
//            @Override
//            public boolean test(String s) {
//                return false;
//            }
//        }
        Predicate<String> predicate=s -> { return s.isEmpty();};
        System.out.println(predicate.test(""));
    }
}
